| Metric | Value |
|---|---|
| AIC | 49.68 |
| BIC | 54.07 |
| R2 | 0.75 |
| R2 (adj.) | 0.74 |
| RMSE | 0.48 |
| Sigma | 0.49 |
For interpretation of performance metrics, please refer to this documentation.
| Parameter | Coefficient | SE | 95% CI | t(30) | p |
|---|---|---|---|---|---|
| (Intercept) | 6.05 | 0.31 | (5.42, 6.68) | 19.59 | < .001 |
| mpg | -0.14 | 0.01 | (-0.17, -0.11) | -9.56 | < .001 |
To find out more about table summary options, please refer to this documentation.
| mpg | Predicted | SE | 95% CI |
|---|---|---|---|
| 10.40 | 4.58 | 0.17 | (4.24, 4.92) |
| 13.01 | 4.21 | 0.14 | (3.94, 4.49) |
| 15.62 | 3.85 | 0.11 | (3.62, 4.07) |
| 18.23 | 3.48 | 0.09 | (3.29, 3.67) |
| 20.84 | 3.11 | 0.09 | (2.93, 3.29) |
| 23.46 | 2.74 | 0.10 | (2.54, 2.95) |
| 26.07 | 2.38 | 0.12 | (2.12, 2.63) |
| 28.68 | 2.01 | 0.15 | (1.69, 2.32) |
| 31.29 | 1.64 | 0.19 | (1.26, 2.02) |
| 33.90 | 1.27 | 0.22 | (0.82, 1.72) |
Variable predicted: wt
Predictors modulated: mpg
We fitted a linear model (estimated using OLS) to predict wt with mpg (formula: wt ~ mpg). The model explains a statistically significant and substantial proportion of variance (R2 = 0.75, F(1, 30) = 91.38, p < .001, adj. R2 = 0.74). The model’s intercept, corresponding to mpg = 0 , is at 6.05 (95% CI (5.42, 6.68), t(30) = 19.59, p < .001). Within this model:
Standardized parameters were obtained by fitting the model on a standardized version of the dataset. 95% Confidence Intervals (CIs) and p-values were computed using a Wald t-distribution approximation.
The model explains a statistically significant and substantial proportion of variance (R2 = 0.75, F(1, 30) = 91.38, p < .001, adj. R2 = 0.74)
---
title: "Regression model summary from `{easystats}`"
output:
flexdashboard::flex_dashboard:
theme:
version: 4
# bg: "#101010"
# fg: "#FDF7F7"
primary: "#0054AD"
base_font:
google: Prompt
code_font:
google: JetBrains Mono
params:
model: model
check_model_args: check_model_args
parameters_args: parameters_args
performance_args: performance_args
---
```{r setup, include=FALSE}
library(flexdashboard)
library(easystats)
# Since not all regression model are supported across all packages, make the
# dashboard chunks more fault-tolerant. E.g. a model might be supported in
# `{parameters}`, but not in `{report}`.
#
# For this reason, `error = TRUE`
knitr::opts_chunk$set(
error = TRUE,
out.width = "100%"
)
```
```{r}
# Get user-specified model data
model <- params$model
# Is it supported by `{easystats}`? Skip evaluation of the following chunks if not.
is_supported <- insight::is_model_supported(model)
if (!is_supported) {
unsupported_message <- sprintf(
"Unfortunately, objects of class '%s' are not yet supported in {easystats}.\n
For a list of supported models, see `insight::supported_models()`.",
class(model)[1]
)
}
```
Model fit
=====================================
Column {data-width=700}
-----------------------------------------------------------------------
### Assumption checks
```{r check-model, eval=is_supported, fig.height=10, fig.width=10}
check_model_args <- c(list(model), params$check_model_args)
do.call(performance::check_model, check_model_args)
```
```{r, eval=!is_supported}
cat(unsupported_message)
```
Column {data-width=300}
-----------------------------------------------------------------------
### Indices of model fit
```{r, eval=is_supported}
# `{performance}`
performance_args <- c(list(model), params$performance_args)
table_performance <- do.call(performance::performance, performance_args)
print_md(table_performance, layout = "vertical", caption = NULL)
```
```{r, eval=!is_supported}
cat(unsupported_message)
```
For interpretation of performance metrics, please refer to <a href="https://easystats.github.io/performance/reference/model_performance.html" target="_blank">this documentation</a>.
Parameter estimates
=====================================
Column {data-width=550}
-----------------------------------------------------------------------
### Plot
```{r dot-whisker, eval=is_supported}
# `{parameters}`
parameters_args <- c(list(model), params$parameters_args)
table_parameters <- do.call(parameters::parameters, parameters_args)
plot(table_parameters)
```
```{r, eval=!is_supported}
cat(unsupported_message)
```
Column {data-width=450}
-----------------------------------------------------------------------
### Tabular summary
```{r, eval=is_supported}
print_md(table_parameters, caption = NULL)
```
```{r, eval=!is_supported}
cat(unsupported_message)
```
To find out more about table summary options, please refer to <a href="https://easystats.github.io/parameters/reference/model_parameters.html" target="_blank">this documentation</a>.
Predicted Values
=====================================
Column {data-width=600}
-----------------------------------------------------------------------
### Plot
```{r expected-values, eval=is_supported, fig.height=10, fig.width=10}
# `{modelbased}`
int_terms <- find_interactions(model, component = "conditional", flatten = TRUE)
con_terms <- find_variables(model)$conditional
if (is.null(int_terms)) {
model_terms <- con_terms
} else {
model_terms <- clean_names(int_terms)
int_terms <- unique(unlist(strsplit(clean_names(int_terms), ":", fixed = TRUE)))
model_terms <- c(model_terms, setdiff(con_terms, int_terms))
}
text_modelbased <- lapply(unique(model_terms), function(i) {
grid <- get_datagrid(model, at = i)
estimate_expectation(model, data = grid)
})
ggplot2::theme_set(theme_modern())
# all_plots <- lapply(text_modelbased, function(i) {
# out <- do.call(visualisation_recipe, c(list(i), modelbased_args))
# plot(out) + ggplot2::ggtitle("")
# })
all_plots <- lapply(text_modelbased, function(i) {
out <- visualisation_recipe(i, show_data = "none")
plot(out) + ggplot2::ggtitle("")
})
see::plots(all_plots, n_columns = round(sqrt(length(text_modelbased))))
```
```{r, eval=!is_supported}
cat(unsupported_message)
```
Column {data-width=400}
-----------------------------------------------------------------------
### Tabular summary
```{r, eval=is_supported, results="asis"}
for (i in text_modelbased) {
tmp <- print_md(i)
tmp <- gsub("Variable predicted", "\nVariable predicted", tmp)
tmp <- gsub("Predictors modulated", "\nPredictors modulated", tmp)
tmp <- gsub("Predictors controlled", "\nPredictors controlled", tmp)
print(tmp)
}
```
```{r, eval=!is_supported}
cat(unsupported_message)
```
Text reports
=====================================
Column {data-width=500}
-----------------------------------------------------------------------
### Textual summary
```{r, eval=is_supported, results='asis', collapse=TRUE}
# `{report}`
text_report <- report(model)
text_report_performance <- report_performance(model)
gsub("]", ")", gsub("[", "(", text_report, fixed = TRUE), fixed = TRUE)
cat("\n")
gsub("]", ")", gsub("[", "(", text_report_performance, fixed = TRUE), fixed = TRUE)
```
```{r, eval=!is_supported}
cat(unsupported_message)
```
Column {data-width=500}
-----------------------------------------------------------------------